/**
 * Created by ElecRoc6 on 2017/6/8.
 */
app.controller('askPageCtrl',
    ['$scope','$location','$routeParams','$http','$sce','$rootScope','$anchorScroll', function ($scope,$location,$routeParams,$http,$sce,$rootScope,$anchorScroll) {
        //fileId
        var articleId =$routeParams.fileId;
        console.log(articleId)
       	$http.jsonp(askUrl+'id='+ articleId +'&siteID=1&jsoncallback=JSON_CALLBACK'
	    ).success(function(datas){
	    	console.log('数据列表');
	    	console.log(datas);
	    	$scope.datas = datas;
	    	if(!datas.group){
	    		$(".group").hide();
	    	}else{
	    		$(".group").show();
	    	}
	    	var ch = $(".content").height();
	    	if(ch>75){
	    		$(".content").addClass('contCss');
	    		$scope.show = function () {
					$(".content").removeClass('contCss');
					$(".down").hide();
					$(".up").show();
				}
		    	$scope.hide = function () {
					$(".content").addClass('contCss');
					$(".down").show();
					$(".up").hide();
				}
	    	}
	        }).error(function(datas){
				console.log('数据出错了')
        });
       
		//获取热门评论接口地址
		$http.jsonp(hotUrl+'siteID=1&subjectID='+ articleId +'&start=0&count=20&jsoncallback=JSON_CALLBACK'
	    ).success(function(datas){
	    	console.log('热门评论');
	    	console.log(datas);
	    	$scope.list = datas.list; 
	        }).error(function(datas){
				console.log('数据出错了')
        });
        //获取最新评论接口地址
        $http.jsonp(newUrl+'siteID=1&subjectID='+ articleId +'&start=0&count=20&jsoncallback=JSON_CALLBACK'
	    ).success(function(datas){
	    	console.log('最新评论');
	    	console.log(datas);
	    	$scope.list = datas.list; 
	        }).error(function(datas){
				console.log('数据出错了')
        });

 }])
app.run(function ($rootScope) {
    $rootScope.data = {
        current: "1" // 1代表张三，2代表李四，3代表王五
    };
    $rootScope.actions =
    {
        setCurrent: function (param) {
            $rootScope.data.current = param;
        }
    }
})